package pteam;
import simulator.Actor;
import simulator.Robot;
import simulator.Sensor;
import simulator.Simulator;

public class ScanActor implements Actor{
	private int pos = 45;
	public static final int INCREMENT = 1;
	public static final int MAX = 45;
	public static final int MIN = 15;
	private int dir = 1;
	public void act(Robot r){
	     
    Simulator.out.println("-- Rotate --");
	r.getServos()[0].turn(INCREMENT*dir);
	r.getServos()[1].turn(-1*INCREMENT*dir);
	pos+=dir;
	if(pos>=MAX || pos<=MIN){
		dir *= -1;
		//r.getServos()[0].turn(-90);
		//r.getServos()[1].turn(90);
		//pos=45;
		//r.goForward();
		//r.waitDistance(10);
	}
	}
	
	public void updateSensors(Sensor[] s){
		String output = new String();
		   for(int i=0; i<s.length; i++){
		     try{
		       //System.out.println(s);
		       //System.out.println(i+": " +s[i].getState()[0]);
		         output = output + s[i].getState()[0] + "	";
		     }catch(Exception e){
		     	e.printStackTrace();
		     }
		   }
		   System.out.println(output);
	}
	
	public String getMaze(){
		return "Super";
	}
}